import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

public class FourthFactory2 {
    static Map<String ,Person> map = new HashMap<>();
    static{
        Properties properties = new Properties();
        try {
            properties.load(FourthFactory2.class.getResourceAsStream("applicationContext.properties"));
        } catch (Exception e) {
            e.printStackTrace();
        }
        Set<Object> set = properties.keySet();
        System.out.println(set);
        for (Object o : set) {
            String str = properties.getProperty(o+"");
            Person person = null;
            try {
                person = (Person) Class.forName(str).newInstance();
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println(o+"");
            System.out.println(person);
            map.put(o+"",person);
        }
    }
    public Person getPerson(String s){
        if (map != null) {
            Set<String> set = map.keySet();
            for (String s1 : set) {
                if (s1.equals(s)) {
                    return map.get(s1);
                }
            }
            return null;
        }
        System.out.println("cuo");
        return null;
        }

}
